Example Program
Pizza & Chili Index
Using a Pizza & Chili Index for searching and the Pizza & Chili String for displaying.
This demonstrates how the Pizza & Chili index libraries may be used in
conjunction with Seqan.
In order to run this example you have to statically link the Pizza & Chili
library (found in seqan/lib/libpizzachili.a).
File "pizzachili.cpp"
1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 |
The following code creates a Pizza & Chili index and assigns it a text.
9 | |
10 | |
11 | |
12 |
Of course, we can access the text as usual:
13 | |
14 |
Now we may create a default finder and search for a substring. The index
is only now created because its evaluation is lazy. Immediately after
the index has been created, the indexText is discarded to save memory.
Notice that the results returned by the finder might not be in the order
of their occurrence in the text.
15 | |
16 | |
17 | |
18 |
We may query the text of the index. Notice that this returns a string
without any real content. The string is lazily evaluated in order to
save memory. Only the substring we are actually displaying will be
loaded into memory.
indexText(..) is a shortcut for getFibre(.., PizzaChili_Text()) .
19 | |
20 | |
21 |
We can save the index structure on disc and load it again.
Notice, however, that not all Pizza & Chili libraries support saving
and loading at the moment. Please refer to the documentation of the
different Pizza & Chili Index Tags for details.
22 | |
23 | |
24 | |
25 | |
26 | |
27 | |
28 | |
29 | |
30 | |
31 | |
32 | |
33 | |
34 |
Output
~/seqan/demos/extra$ make pizzachili
~/seqan/demos/extra$ ./pizzachili
Test the alphabet-friendly FM index:
This is the best test with a bast jest.
Hit at position 13
Hit at position 18
Hit at position 35
infix(text, 12, 21): best test
This is the best test with a bast jest.
Test the compressed compact suffix array index:
This is the best test with a bast jest.
Hit at position 13
Hit at position 18
Hit at position 35
infix(text, 12, 21): best test
This is the best test with a bast jest.
~/seqan/demos/extra$
SeqAn - Sequence Analysis Library - www.seqan.de